package cn.com.roy.thread.t6_2.singleton_7_1;

import java.io.ObjectStreamException;
import java.io.Serializable;

public class MyObject implements Serializable {
    private static class MyObjectHandler {
        private static MyObject myObject = new MyObject();
    }

    public MyObject() {

    }

    public static MyObject getInstance() {
        return MyObjectHandler.myObject;
    }

    protected Object readResolve() throws ObjectStreamException{
        System.out.println("调用了readResolve方法！");
        return MyObjectHandler.myObject;
    }
}
